package com.twu.solo;

import java.io.PrintStream;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: thoughtworker
 * Date: 10/10/13
 * Time: 1:46 PM
 * To change this template use File | Settings | File Templates.
 */
public class League {
    public List<Team> teams;
    public PrintStream printStream;

    public League(PrintStream printStream, List<Team> teams) {
        this.printStream = printStream;
        this.teams = teams;
    }

    public void printPlayersAndCoaches() {
        String playersAndCoachesString = "";
        for(Team team: teams) {
            playersAndCoachesString+= (team.stringOfPlayers() + team.stringOfCoaches());
        }
        printStream.println(playersAndCoachesString);
    }


    public void printPlayerInfo(String playerName) {
      loop:  for(Team team : teams) {
                for(Player player : team.playerList)  {
                    if(player.name.equals(playerName)){
                        player.printInfo();
                        break loop;
                    }
                }
        }
    }
}
